import React from 'react'
import i18n from '../../i18n'
import {useTranslation} from 'react-i18next'
function SwitchLang() {
  const {t} = useTranslation()
  //切换语言
  const handleLang=(lang)=>{
       i18n.changeLanguage(lang)
       //本地存储语言
       localStorage.setItem('lang',lang)
  }
  return (
    <div className='switchLang'>
       <h1>{t('title')}</h1>
       <p>{t('text')}</p>
       <p>{t('content')}</p>
        <select value={i18n.language} onChange={(e)=>handleLang(e.target.value)}>
              <option value="zh">中文</option>
              <option value="en">English</option>
        </select>
        
       

    </div>
  )
}

export default SwitchLang
